package com.kitty.game.player.serializer;

import com.kitty.game.role.model.Role;
import com.kitty.game.activity.model.user.RoleActivity;
import com.kitty.game.utils.JsonUtils;
import org.apache.commons.lang3.StringUtils;
import org.nutz.json.Json;
import org.slf4j.LoggerFactory;

public class RoleActivitySerializer implements IPlayerPropSerializer {
    @Override
    public void serialize(Role player) {
        if (player.getActivity() != null) {
            player.setActivityJson(Json.toJson(player.getActivity()));
        }
    }

    @Override
    public void deserialize(Role player) {
        String json = player.getActivityJson();
        if (StringUtils.isNotEmpty(json)) {
            player.setActivity(Json.fromJson(RoleActivity.class,json));
        }
    }
}
